/**
 * 人才
 */
module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, DATE, STRING, TEXT } = Sequelize;

    await queryInterface.createTable('talent', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      uuid: { type: STRING(36), unique: true },
      name: STRING(50),
      sex: INTEGER, // 0为女， 1为男
      tel: STRING(50),
      email: STRING(50),
      age: INTEGER,
      address: STRING(255),
      role: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'title',
          },
          key: 'uuid',
        },
      }, // 职称
      post: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'position',
          },
          key: 'uuid',
        },
      }, // 职务名
      education: STRING(10), // 学历
      unit: STRING(50), // 工作单位
      type: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'organization_type',
          },
          key: 'uuid',
        },
      }, // 工作单位性质
      fk_applicationArea: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'application_area',
          },
          key: 'uuid',
        },
      }, // 行业领域
      fk_organization: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'organization',
          },
          key: 'uuid',
        },
      },
      pk_type: {
        type: STRING(36),
        references: {
          model: {
            tableName: 'talent_classfication',
          },
          key: 'uuid',
        },
      }, // 人才类型（外键：talents_classfication）
      filler: {
        type: Sequelize.DataTypes.STRING(36),
      }, // 填写人
      description: TEXT, // 人才描述
      updateTime: DATE, // 更新日期
      createdAt: DATE,
      updatedAt: DATE,
    });
  },

  down: async queryInterface => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('talent');
  },
};
